package com.example.game_dafangdaxie.View;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.example.game_dafangdaxie.StringConstant.Point;
import com.example.game_dafangdaxie.StringConstant.TouchXY;

/***
 * 画棋子
 * create by LiuTong
 * 2021.9.27
 */

public class drawPiece {
    /***
     *
     * @param pos -1 不是最后一个，不需要画十字标志
     */
    public static Canvas draw(Canvas canvas, Point startPoint, float spacing, TouchXY touchXY,int pos){
        Paint paint=new Paint();
        paint.setShadowLayer(15,10,15, Color.GRAY);
        switch (touchXY.play){
            case 0:
                paint.setARGB(240,188,43,63);
                break;
            case 1:
                paint.setARGB(240,0,150,136);
                break;
        }

        paint.setStrokeWidth(spacing/8);
        float x=startPoint.x+touchXY.point.x*spacing;
        float y=startPoint.y+touchXY.point.y*spacing;
        canvas.drawCircle(x,y,spacing/4,paint);
        if(pos!=-1){
            Paint paint1=new Paint();
            paint1.setColor(Color.WHITE);
            canvas.drawLine(x-20,y,x+20,y,paint1);
            canvas.drawLine(x,y-20,x,y+20,paint1);
        }
        return canvas;

    }
}
